<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>

        // 提取数组中的值
        // var arr = [1, 2 , 3]

        // let [a, b, c] = [1, 2, 3]
        // console.log(a, b, c)


        //匹配模式：等号两边模式一样，变量就会被赋予对应的值

        // let [foo, [[bar], baz]] = [1, [[2], 3]];

        //左边与右边模式一样，右边可以给左边赋值
        // console.log(foo);
        // console.log(bar);
        // console.log(baz);

        //案例
        //"..."为扩展运算符；会将2,3,4,5，打包成一个数组
        // let [head, ...tail] = [1, 2, 3, 4, 5];

        // console.log(head);
        // console.log(tail);

        //案例
        const items = [
            ['name', '张三'],
            ['title', 'Author']

        ];

        items.forEach(([key, value]) => console.log(key, value));

        items.forEach(function([key, value])) {
            console.log(key, value)
        }

    </script>
</body>
</html>